package com.tedu.demo;

import java.util.Arrays;
import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        int[] a = getShuzu();
        Paixu(a);
    }

    private static int[] getShuzu() {
        System.out.println("请输入数组长度");
        int len = new Scanner(System.in).nextInt();
        int[] shuzu = new int[len];
        System.out.println("请输入"+len+"个数字:");
        for (int i = 0; i < len; i++) {
            shuzu[i] = new Scanner(System.in).nextInt();
        }
        return shuzu;
    }
    public static void Paixu(int[] shuzu){
        for (int i = 0; i < shuzu.length-1; i++) {
            for (int j = 0; j < shuzu.length-1-i; j++) {
                if (shuzu[j]>shuzu[j+1]){
                    int a = shuzu[j+1];
                    shuzu[j+1] = shuzu[j];
                    shuzu[j] = a;
                }
            }
        }
        String b = Arrays.toString(shuzu);
        System.out.println(b);
    }
}
